package com.designpatterns.interpreterpattern.impl;

import com.designpatterns.interpreterpattern.Expression;

//Expression接口的实现类
public class AndExpression implements Expression
{

	private Expression expr1 = null;
	private Expression expr2 = null;

	// 两个参数的构造函数
	public AndExpression(Expression expr1, Expression expr2)
	{
		this.expr1 = expr1;
		this.expr2 = expr2;
	}

	// 写法上是使用接口的抽象方法
	// 实际运行后内存中指向TerminalExpression
	@Override
	public boolean interpret(String context)
	{
		return expr1.interpret(context) && expr2.interpret(context);
	}

}
